<template>
	<view class="custom-nav">
		<view class="back">
			<image @click="toback" :src="backIcon" class="back-icon"></image>
			<image @click="tohome" :src="homeIcon" class="hone-icon" mode=""></image>
		</view>
		<view class="custom-title">{{ title }}</view>
		<view class="search-container" @click="search">
			<image :src="searchIcon" class="search-icon"></image>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			title: {
				type: String,
				default: '惠商城'
			},
			backIcon: {
				type: String,
				default: '/static/icon_back_white.png'
			},
			homeIcon: {
				type: String,
				default: '/static/主页white.png'
			},
			searchIcon: {
				type: String,
				default: '/static/icon_search_white.png'
			}
		},
		methods: {
			// 返回上一级
			toback() {
				// this.$emit('search-click');
				uni.navigateBack({
					delta: 1 // 返回上一级页面
				});
			},
			// 跳转到搜索页
			search() {
				uni.navigateTo({
					url: `/pages/toSearch/toSearch`
				});
			},
			tohome() {
				uni.switchTab({
					url: "/pages/index/index"
				});
			}
		},

	}
</script>

<style scoped>
	.custom-nav {
		position: fixed;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 160rpx;
		background-color: #ff5218;
		color: white;
		z-index: 1111 !important;
	}

	.back {
		width: 80px;
		height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.back-icon {
		width: 24px;
		height: 24px;
		margin-top: 70rpx;
		margin-left: 10rpx;
	}

	.hone-icon {
		width: 24px;
		height: 24px;
		margin-left: 20rpx;
		margin-top: 70rpx;
	}

	.custom-title {
		font-size: 18px;
		text-align: center;
		position: relative;
		height: 100rpx;
		display: flex;
		margin: 0 auto;
		margin-top: 120rpx;
		font-weight: bold;
	}

	.search-container {
		display: flex;
		width: 80px;
		height: 44px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.search-icon {
		width: 24px;
		height: 24px;
		margin-top: 70rpx;
	}
</style>